import React, { Component } from 'react'
import { connect } from 'react-redux'
import LiveSwiperItem from './LiveSwiperItem'

class LiveSwiper extends Component {
  renderItem() {
    var { images, index, info } = this.props
    var _images = []
    if (info.type === 2) {
      _images = _images.concat([{
        is_video: false,
        img: info.cover
      }])
    } else {
      _images = _images.concat(images)
    }
    const list = []
    _images.map((item, index) => {
      list.push(
        <LiveSwiperItem item={item} key={index} index={index}/>
      )
    })
    return list
  }
  render() {
    return (
      <div className="live_swiper">
        { this.renderItem() }
      </div>
    )
  }
}

const mapStateToProps = (state) => {
  return Object.assign({}, state.LiveState, {
    info: state.MainScreenState.info
  })
}

export default connect(mapStateToProps)(LiveSwiper)
